﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Diagnostics;
using System.Windows.Browser;

namespace Manas.Silverlight.DynamicDeepZoom.TileSources
{
    public class FixedImageTileSource : MultiScaleTileSource
    {
        Uri imageUri;

        /// <summary>
        /// Create a new instance of the tile source 
        /// </summary>
        /// <param name="config"></param>
        public FixedImageTileSource(IConfiguration config)
            : base(config.ImageWidth, config.ImageHeight, config.TileWidth, config.TileHeight, 0)
        {
            Uri source = HtmlPage.Document.DocumentUri;
            UriBuilder builder = new UriBuilder(source.Scheme, source.Host, source.Port, "/Tiles/Squares");
            imageUri = builder.Uri;
        }

        protected override void GetTileLayers(int tileLevel, int tilePositionX, int tilePositionY, System.Collections.Generic.IList<object> tileImageLayerSources)
        {
            Debug.WriteLine("Requested level {0} at X={1} Y={2}", tileLevel, tilePositionX, tilePositionY);
            tileImageLayerSources.Add(imageUri);
        }
    }
}
